import Vue from 'vue'
import VueRouter from 'vue-router'
import Home from '../views/Home.vue'

Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    name: 'Home',
    component: Home
  },
  {
    path: '/Fater',
    name: 'Fater',
    component: () => import('../views/Fater.vue')
  },
  {
    path:'/Fater2',
    name:'Fater2',
    component:()=>import('../views/Fater2.vue')
  }
]

const router = new VueRouter({
  routes,
  
})

//设置路由导航守卫
router.beforeEach((to, from,next) => {
  // to要去的页面 from从哪里来 next放行 
  console.log(to,from );
  if(to.path == '/'){
    next()
  }
 next()
})
router.afterEach((to, from) => {
  // to and from are both route objects.
  console.log(to,from);
})

export default router
